其他
U3D逆向-Mono另类解密
MonoImage *
mono_image_open_from_data_with_name (char *data, guint32 data_len, gboolean need_copy, MonoImageOpenStatus *status, gboolean refonly, const char *name)
{
return mono_image_open_from_data_internal (data, data_len, need_copy, status, refonly, FALSE, name);
}
MonoImage *
mono_image_open_from_data_internal (char *data, guint32 data_len, gboolean need_copy, MonoImageOpenStatus *status, gboolean refonly, gboolean metadata_only,
const char *name)
{
MonoCLIImageInfo *iinfo;
MonoImage *image;
char *datac;
if (!data || !data_len) {
if (status)
*status = MONO_IMAGE_IMAGE_INVALID;
return NULL;
}
datac = data;
if (need_copy) {
datac = (char *)g_try_malloc (data_len);
if (!datac) {
if (status)
*status = MONO_IMAGE_ERROR_ERRNO;
return NULL;
}
memcpy (datac, data, data_len);
}
image = g_new0 (MonoImage, 1);
image->raw_data = datac;
image->raw_data_len = data_len;
image->raw_data_allocated = need_copy;
image->name = (name == NULL) ? g_strdup_printf ("data-%p", datac) : g_strdup(name);
iinfo = g_new0 (MonoCLIImageInfo, 1);
image->image_info = iinfo;
image->ref_only = refonly;
image->metadata_only = metadata_only;
image->ref_count = 1;
image = do_mono_image_load (image, status, TRUE, TRUE);
if (image == NULL)
return NULL;
return register_image (image);
}
static MonoImage *
register_image (MonoImage *image)
{
MonoImage *image2;
GHashTable *loaded_images = get_loaded_images_hash (image->ref_only); // 重点关注对象
mono_images_lock ();
image2 = (MonoImage *)g_hash_table_lookup (loaded_images, image->name);
if (image2) {
/* Somebody else beat us to it */
mono_image_addref (image2);
mono_images_unlock ();
mono_image_close (image);
return image2;
}
GHashTable *loaded_images_by_name = get_loaded_images_by_name_hash (image->ref_only);
g_hash_table_insert (loaded_images, image->name, image); // 重点关注对象
if (image->assembly_name && (g_hash_table_lookup (loaded_images_by_name, image->assembly_name) == NULL))
g_hash_table_insert (loaded_images_by_name, (char *) image->assembly_name, image);
mono_images_unlock ();
return image;
}
struct _MonoImage {
………
guint32 raw_data_len;
char *raw_data; //模块二进制
char *name; //模块名
…………
}
MonoImage *
mono_image_open_from_data_internal (char *data, guint32 data_len, gboolean need_copy, MonoImageOpenStatus *status, gboolean refonly, gboolean metadata_only,
const char *name)
{
MonoCLIImageInfo *iinfo;
MonoImage *image;
char *datac;
if (!data || !data_len) {
if (status)
*status = MONO_IMAGE_IMAGE_INVALID;
return NULL;
}
datac = data;
if (need_copy) {
datac = (char *)g_try_malloc (data_len);
if (!datac) {
if (status)
*status = MONO_IMAGE_ERROR_ERRNO;
return NULL;
}
memcpy (datac, data, data_len);
}
image = g_new0 (MonoImage, 1);
image->raw_data = datac; <<<<<<<<<<<<<<<
image->raw_data_len = data_len; <<<<<<<<<<<<<<<
image->raw_data_allocated = need_copy;
image->name = (name == NULL) ? g_strdup_printf ("data-%p", datac) : g_strdup(name); <<<<<<<<<<<<<<<
iinfo = g_new0 (MonoCLIImageInfo, 1);
image->image_info = iinfo;
image->ref_only = refonly;
image->metadata_only = metadata_only;
image->ref_count = 1;
image = do_mono_image_load (image, status, TRUE, TRUE);
if (image == NULL)
return NULL;
return register_image (image);
}
__int64 __fastcall sub_18006CA20(__int64 data, unsigned int data_len, int need_cpy, _DWORD *status, __int64 refonly, char metadata_only, __int64 name)
{
__int64 len; // r14
_DWORD *v8; // rdi
char v9; // si
__int64 data_; // rbx
__int64 data__; // rbp
__int64 v12; // rax
__int64 result; // rax
__int64 v14; // rbx
__int64 m_name; // rax
signed __int64 v16; // rax
__int64 v18; // rax
__int64 v19; // rax
len = data_len;
v8 = status;
v9 = need_cpy;
data_ = data;
if ( data && data_len )
{
data__ = data;
if ( need_cpy )
{
v12 = sub_180004B80(data_len);
data__ = v12;
if ( !v12 )
{
if ( v8 )
*v8 = 1;
return 0i64;
}
sub_180314D40(v12, data_, len);
}
v14 = sub_180004AE0(1856i64);
*(_BYTE *)(v14 + 0x1C) &= 0xFDu;
*(_BYTE *)(v14 + 0x1C) |= 2 * (v9 & 1);
*(_QWORD *)(v14 + 0x10) = data__; //data
*(_DWORD *)(v14 + 0x18) = len; //data_len
if ( name )
{
v16 = -1i64;
while ( *(_BYTE *)(name + v16++ + 1) != 0 )
;
m_name = sub_180004A10(name, (unsigned int)(v16 + 1));
}
else
{
m_name = sub_180006230("data-%p", data__);
}
*(_QWORD *)(v14 + 0x20) = m_name; //name
v18 = sub_180004AE0(408i64);
*(_BYTE *)(v14 + 0x1C) &= 0xBFu;
*(_BYTE *)(v14 + 0x1D) &= 0xFEu;
*(_QWORD *)(v14 + 0x50) = v18;
*(_DWORD *)v14 = 1;
*(_BYTE *)(v14 + 0x1C) |= (refonly & 1) << 6;
*(_BYTE *)(v14 + 0x1D) |= metadata_only & 1;
v19 = sub_1800699B0(v14, v8, 1i64);
if ( !v19 )
return 0i64;
result = sub_18006D6D0(v19);
}
else
{
if ( status )
*status = 3;
result = 0i64;
}
return result;
}
0x10 raw_data
0x18 raw_data_len
0x20 name
看雪ID:PlaneJun
https://bbs.pediy.com/user-home-826671.htm
*本文由看雪论坛 PlaneJun 原创,转载请注明来自看雪社区。
# 往期推荐
球分享
球点赞
球在看
点击“阅读原文”,了解更多!